using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace HMEngine.HMCameras {
    public class HMCameraManager : DrawableGameComponent {
        private static readonly Dictionary<string, HMCamera> myCameras = new Dictionary<string, HMCamera>();

        public static HMCamera DefaultCamera { get; private set; }
        public static HMCamera ActiveCamera { get; private set; }

        public HMCameraManager(Game game) : base(game) { }

        public static void AddCamera(string name, HMCamera newCamera) {
            myCameras.Add(name, newCamera);
        }

        public static void SetActiveCamera(string name) {
            if (myCameras.ContainsKey(name)) ActiveCamera = myCameras[name];
        }

        protected override void LoadContent() {
            DefaultCamera = new HMCamera(GraphicsDevice.Viewport);

            myCameras.Add("HMEngine.HMCameras.DefaultCamera", DefaultCamera);
            SetActiveCamera("HMEngine.HMCameras.DefaultCamera");

            base.LoadContent();
        }

        public override void Update(GameTime gameTime) {
            foreach (HMCamera camera in myCameras.Values) {
                camera.Update();
            }
            
            base.Update(gameTime);
        }
    }
}